package com.tancire.web.controller.system;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tancire.common.annotation.Log;
import com.tancire.common.core.controller.BaseController;
import com.tancire.common.core.domain.AjaxResult;
import com.tancire.common.enums.BusinessType;
import com.tancire.system.domain.SysTodayAmount;
import com.tancire.system.service.ISysTodayAmountService;
import com.tancire.common.utils.poi.ExcelUtil;
import com.tancire.common.core.page.TableDataInfo;

/**
 * 广告收入Controller
 *
 * @author chenchao
 * @date 2023-12-31
 */
@RestController
@RequestMapping("/system/todayAmount")
public class SysTodayAmountController extends BaseController {
    @Resource
    private ISysTodayAmountService sysTodayAmountService;

    /**
     * 查询广告收入列表
     */
    @PreAuthorize("@ss.hasPermi('system:todayAmount:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysTodayAmount sysTodayAmount) {
        startPage();
        List<SysTodayAmount> list = sysTodayAmountService.selectSysTodayAmountList(sysTodayAmount);
        return getDataTable(list);
    }

    /**
     * 导出广告收入列表
     */
    @PreAuthorize("@ss.hasPermi('system:todayAmount:export')")
    @Log(title = "广告收入", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysTodayAmount sysTodayAmount) {
        List<SysTodayAmount> list = sysTodayAmountService.selectSysTodayAmountList(sysTodayAmount);
        ExcelUtil<SysTodayAmount> util = new ExcelUtil<SysTodayAmount>(SysTodayAmount.class);
        util.exportExcel(response, list, "广告收入数据");
    }

    /**
     * 获取广告收入详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:todayAmount:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(sysTodayAmountService.selectSysTodayAmountById(id));
    }

    /**
     * 新增广告收入
     */
    @PreAuthorize("@ss.hasPermi('system:todayAmount:add')")
    @Log(title = "广告收入", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysTodayAmount sysTodayAmount) {
        return toAjax(sysTodayAmountService.insertSysTodayAmount(sysTodayAmount));
    }

    /**
     * 修改广告收入
     */
    @PreAuthorize("@ss.hasPermi('system:todayAmount:edit')")
    @Log(title = "广告收入", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysTodayAmount sysTodayAmount) {
        return toAjax(sysTodayAmountService.updateSysTodayAmount(sysTodayAmount));
    }

    /**
     * 删除广告收入
     */
    @PreAuthorize("@ss.hasPermi('system:todayAmount:remove')")
    @Log(title = "广告收入", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysTodayAmountService.deleteSysTodayAmountByIds(ids));
    }
}
